package com.magoldeditor.controller;

import java.awt.event.ActionEvent;
import com.magoldeditor.model.IMap;

public class MenuHandler implements Cloneable, MenuMouseListener {
	
	private IMap map = null;
	
	private String itemName = null;
	
	public MenuHandler(IMap map) {
		if (map != null) this.map = map;
	}
	
	@Override
	public String getItemName() {
		return this.itemName;
	}

	@Override
	public void setItemName(String itemName) {
		this.itemName = itemName;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if (this.itemName != null && this.map != null) map.toChoose(this.itemName);
	}
	
	@Override
	public MenuMouseListener clone() {
		try {
			return (MenuMouseListener) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		
		return null;
	}
}
